package com.sunny.util.struts2;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * Created by tongchengke on 2016/8/25.
 */
public abstract class BaseAction<T> extends ActionSupport implements ServletRequestAware, ServletResponseAware, SessionAware, ModelDriven<T> {

    /**
     * <p>HttpServletRequest request 对象 </p>
     */
    protected HttpServletRequest request;

    /**
     * <p>HttpServletResponse response 对象 </p>
     */
    protected HttpServletResponse response;

    /**
     * <p>Map<String, Object> session 对象 </p>
     */
    protected Map<String, Object> session;

    /**
     * 设置 request
     * @param request
     */
    @Override
    public void setServletRequest(HttpServletRequest request) {
        this.request = request;
    }

    /**
     * 设置 response
     * @param response
     */
    @Override
    public void setServletResponse(HttpServletResponse response) {
        this.response = response;
    }

    /**
     * 设置 session
     * @param session
     */
    @Override
    public void setSession(Map<String, Object> session) {
        this.session=session;
    }
}
